#include <iostream>
#include <algorithm>
using namespace std;
struct stu
{
	string id;
	int score;
};
stu student[1000];
bool cmp(stu a,stu b){
	if(a.score>b.score) return true;
	else if(a.score==b.score){
		return a.id<b.id;
	}
	else return false;
}
int main()
{
	int n,m,g;
	while(cin>>n){
		int score[100000];
		if(n==0) break;
		cin>>m>>g;
		for(int i=0;i<m;i++)cin>>score[i];
		for(int i=0;i<n;i++){
			cin>>student[i].id;
			student[i].score=0;
			int k;
			cin>>k;
			for(int j=0;j<k;j++){
				int num;
				cin>>num;
				student[i].score+=score[num-1];
			}
		}
		sort(student,student+n,cmp);
		int ans=0;
		for(int i=0;i<n;i++){
			if(student[i].score>=g) ans++;
		}
		cout<<ans<<endl;
		for(int j=0;j<ans;j++){
			cout<<student[j].id<<" "<<student[j].score<<endl;
		}
	}
} 
